home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / VIEWEX.PAK / SIMPVW.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  3KB  |  121 lines

  1. // simpvw.cpp : implementation of the simple view classes
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13.  
  14.  
  15. #include "stdafx.h"
  16. #include "viewex.h"
  17.  
  18. #ifdef _DEBUG
  19. #undef THIS_FILE
  20. static char BASED_CODE THIS_FILE[] = __FILE__;
  21. #endif
  22.  
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CTextView
  25.  
  26. IMPLEMENT_DYNCREATE(CTextView, CView)
  27.  
  28. BEGIN_MESSAGE_MAP(CTextView, CView)
  29.     //{{AFX_MSG_MAP(CTextView)
  30.     ON_WM_MOUSEACTIVATE()
  31.     //}}AFX_MSG_MAP
  32. END_MESSAGE_MAP()
  33.  
  34. /////////////////////////////////////////////////////////////////////////////
  35. // CTextView construction/destruction
  36.  
  37. CTextView::CTextView()
  38. {
  39. }
  40.  
  41. CTextView::~CTextView()
  42. {
  43. }
  44.  
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CTextView drawing
  47.  
  48. void CTextView::OnDraw(CDC* pDC)
  49. {
  50.     CMainDoc* pDoc = GetDocument();
  51.  
  52.     CRect rect;
  53.     GetClientRect(rect);
  54.     pDC->SetTextAlign(TA_BASELINE | TA_CENTER);
  55.     pDC->SetTextColor(pDoc->m_colorData);
  56.     pDC->SetBkMode(TRANSPARENT);
  57.     // center in the window
  58.     pDC->TextOut(rect.Width() / 2, rect.Height() / 2,
  59.         pDoc->m_strData, pDoc->m_strData.GetLength());
  60. }
  61.  
  62.  
  63. int CTextView::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
  64. {
  65.     // side-step CView's implementation since we don't want to activate
  66.     //  this view
  67.     return CWnd::OnMouseActivate(pDesktopWnd, nHitTest, message);
  68. }
  69.  
  70. /////////////////////////////////////////////////////////////////////////////
  71. // CColorView
  72.  
  73. IMPLEMENT_DYNCREATE(CColorView, CView)
  74.  
  75. BEGIN_MESSAGE_MAP(CColorView, CView)
  76.     //{{AFX_MSG_MAP(CColorView)
  77.     ON_WM_MOUSEACTIVATE()
  78.     //}}AFX_MSG_MAP
  79. END_MESSAGE_MAP()
  80.  
  81. /////////////////////////////////////////////////////////////////////////////
  82. // CColorView construction/destruction
  83.  
  84. CColorView::CColorView()
  85. {
  86. }
  87.  
  88. CColorView::~CColorView()
  89. {
  90. }
  91.  
  92. /////////////////////////////////////////////////////////////////////////////
  93. // CColorView drawing
  94.  
  95. void CColorView::OnDraw(CDC* pDC)
  96. {
  97.     CMainDoc* pDoc = GetDocument();
  98.  
  99.     CRect rect;
  100.     GetClientRect(rect);
  101.  
  102.     // fill the view with the specified color
  103.     CBrush br(pDoc->m_colorData);
  104.     pDC->FillRect(rect, &br);
  105. }
  106.  
  107. int CColorView::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
  108. {
  109.     // side-step CView's implementation since we don't want to activate
  110.     //  this view
  111.     return CWnd::OnMouseActivate(pDesktopWnd, nHitTest, message);
  112. }
  113.  
  114. void CColorView::OnActivateView(BOOL, CView*, CView*)
  115. {
  116.     ASSERT(FALSE);      // output only view - should never be active
  117. }
  118.  
  119.  
  120. /////////////////////////////////////////////////////////////////////////////
  121.